package client;

import general.AuctionOptions;
import general.Product;
import general.ProductRecord;

import java.sql.Date;
import java.util.LinkedList;

public class Main {

	public static void main(String[] args) {
		// Start up client
		Client client = new Client();
		
		// Add product1
		Product product1 = new Product("Football");
		Date startTime1 = new Date(System.currentTimeMillis());
		Date endTime1 = new Date(System.currentTimeMillis() + 1000 * 60 * 10);
		AuctionOptions product1Options = new AuctionOptions(startTime1, endTime1, 10);
		System.out.println("Add product football");
		client.addProduct(product1, product1Options);
		
		// Add product2
		Product product2 = new Product("Basketball");
		Date startTime2 = new Date(System.currentTimeMillis() + 1000 * 10);
		Date endTime2 = new Date(System.currentTimeMillis() + 1000 * 60 * 20);
		AuctionOptions product2Options = new AuctionOptions(startTime2, endTime2, 10);
		System.out.println("Add product basketball");
		client.addProduct(product2, product2Options);
		
		// Search all products with ball
		System.out.println("Search for products with ball");
		LinkedList<ProductRecord> resultList = client.searchProducts("ball");
		System.out.println("Nr of products found: " + resultList.size());
		
		// Stay alive
		try {
			Thread.sleep(Long.MAX_VALUE);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}	
	}

}
